
$(function(){
    $(".feedback").click(function(){
        if($(".feedbackbox")!="undefined"){
        	$("body").css({'overflow-y':'hidden','padding':'0 17px 0 0'})
			$(".suspend").css('margin-left',"577.5px");
            $(".feedbackbox").show();
        }
    })

    var oCss = document.createElement("link");
    oCss.setAttribute("rel", "stylesheet");
    oCss.setAttribute("type", "text/css");
    oCss.setAttribute("href", 'css/feedback.css');
    document.getElementsByTagName("head")[0].appendChild(oCss);

    var html=  "<div class='feedbackbox'>" +
        "<div class='filter'></div>"+
        "<div class='cont'>"+
        "<div class='title ellipsis_add'>请简单阐述您的问题内容，我们收到会尽快与您进行沟通</div>"+
        "<div class='chose'>"+
        "<span style='color:#7f7f7f;'>反馈类型</span>"+
        "<span class='chose1'><label for='ask' class='selected'></label><input type='radio' name='feedbacktype' class='feedtype' id='ask' checked></span><span>质询</span>"+
        "<span class='chose2'><label for='provide' class='unselect'></label><input type='radio' name='feedbacktype'class='feedtype' id='provide' ></span><span>建议</span>"+
        "<span class='chose2'><label for='complain' class='unselect'></label><input type='radio' name='feedbacktype' class='feedtype' id='complain' ></span><span>投诉</span>"+
        "</div>"+
        "<div class='intitle'>"+
        "<input type='text' placeholder='请输入您的标题'>"+
        "</div>"+
        "<div class='problem'>"+
        "<textarea type='text' placeholder='请描述您的问题,此处限制4000字以内' ></textarea>"+
        "</div>"+
        "<div class='uploaddiv'>"+
        "<input type='file' class='upload'>"+
        "<span class='upimg'>上传附件</span>"+
        "<span class='uploaddes1'>最多可上传一个文件，大小50M以内</span>"+
        "<span class='uploaddes2'>格式html/htm/pdf/doc/docx/txt/xls/xlsx/zip/rar/bmp/jpg/png/gif</span>"+
        "</div><div class='result clearfix'><p>结果名字</p><div class='close'></div></div>"+
        "<div class='connecttitle'>请留下您的联系方式以便我们及时给您反馈</div>"+
        "<div>"+
        "<span class='intitle1'><input type='text' placeholder='请输入您的手机号'></span>"+
        "<span class='intitle2'><input type='text' placeholder='请输入您的邮箱'></span>"+
        "</div>"+
        "<div class='closebutton'></div>"+
        "<a href='' class='btn'>提交我的反馈</a>"+
        "<div class='warm'>请输入正确的手机号</div>"
    "</div>"+
    "</div>"
    $("body").append(html);

    $(".feedbackbox .chose label").live('click',function(){
        var className=$(this).attr("class");
        if(className.indexOf("selected")<0){
            $(".chose").find(".selected").removeClass("selected").addClass("unselect");
            $(this).removeClass("unselect").addClass("selected");
        }
    })

    $(".feedbackbox .closebutton").live("click",function(){
        $(".feedbackbox").hide();
//      $("body").css('overflow','scroll');
        $("body").css({'overflow-y':'scroll','padding':'0 0px 0 0'});
		$(".suspend").css('margin-left',"586px")
    })

    //placeholder
    supportPlaceholder = 'placeholder'in document.createElement('input'),
        placeholder = function (input) {

            var text = input.attr('placeholder'),
                defaultValue = input.defaultValue;

            if (!defaultValue) {
                input.val(text);
                input.addClass("phcolor");
                input.css('color','#666');
            }
            input.focus(function () {
                if (input.val() == text) {
                    $(this).val("");
                }
            });
            input.blur(function () {
                if (input.val() == "") {
                    $(this).val(text).addClass("phcolor");
                    input.css('color','#666');
                }
            });
            //输入的字符不为灰色
            input.keydown(function () {

                $(this).removeClass("phcolor");
                input.css('color','black');
            });
        };

    //当浏览器不支持placeholder属性时，调用placeholder函数
    if (!supportPlaceholder) {

        $('input,textarea').each(function () {

//          text = $(this).attr("placeholder");

            if ($(this).attr("type") == "text") {

                placeholder($(this));
            }
        });
    }
})